/*
 * MessageLabel.java
 *
 * Created on Feb 25, 2008
 *
 * Copyright(c) 2008 OpenOak Technologies 
 * Licensed under the OpenOak Learning License
 */

package com.openoak.textfield;

import java.awt.Color;
import javax.swing.JLabel;

/**
 *  Shows a message label which can display warnings or errors by altering its color
 * 
 *  @author Steven C. Daniel - Copyright (c) 2008
 *  @author OpenOak Technologies - www.openoak.com
 *  @version 1.0
 */
public class MessageLabel extends JLabel{

    private Color plainColor = new Color(200, 200, 200);
    private Color warningColor = Color.YELLOW;
    private Color errorColor = Color.PINK;
    
    public MessageLabel() {

    }

    /**
     * Clears out the message and resets the color
     */
    public void clearMessage(){
        this.setText("");
        this.setBackground(plainColor);
        this.setOpaque(false);
    }
    
    /**
     * Sets a normal message with the normal background color
     * @param message The message to display
     */
    public void setMessage(String message){
        this.setText(message);
        this.setBackground(plainColor);
        this.setOpaque(false);
    }
    
    /**
     * Sets a warning message with a yellow background
     * @param message The message to display
     */
    public void setWarningMessage(String message){
        this.setText(" " + message + " ");
        this.setBackground(warningColor);
        this.setOpaque(true);
    }
    
    /**
     * Sets an error message with a pink background
     * @param message The message to display
     */
    public void setErrorMessage(String message){
        this.setText(" " + message + " ");
        this.setBackground(errorColor);
        this.setOpaque(true);
    }
    
}
